package cl.ncx.cmvrc.persistence.base.entities.personas;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import cl.ncx.cmvrc.persistence.base.entities.vehiculo.FichaVehiculo;

/**
 * Cliente entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "cliente", schema = "base", uniqueConstraints = @UniqueConstraint(columnNames = "persona"))
@SequenceGenerator(name = "cliente_seque", sequenceName = "base.clientes_cliente_id_seq")
public class Cliente implements java.io.Serializable {

	// Fields

	private Integer clienteId;
	private Persona persona;
	private Set<FichaVehiculo> fichaVehiculos = new HashSet<FichaVehiculo>(0);

	// Constructors

	/** default constructor */
	public Cliente() {
	}

	/** minimal constructor */
	public Cliente(Integer clienteId) {
		this.clienteId = clienteId;
	}

	/** full constructor */
	public Cliente(Integer clienteId, Persona persona,
			Set<FichaVehiculo> fichaVehiculos) {
		this.clienteId = clienteId;
		this.persona = persona;
		this.fichaVehiculos = fichaVehiculos;
	}

	// Property accessors
	@Id
	@Column(name = "cliente_id", unique = true, nullable = false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "cliente_seque")
	public Integer getClienteId() {
		return this.clienteId;
	}

	public void setClienteId(Integer clienteId) {
		this.clienteId = clienteId;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "persona", nullable = false)
	public Persona getPersona() {
		return this.persona;
	}

	public void setPersona(Persona persona) {
		this.persona = persona;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "cliente")
	public Set<FichaVehiculo> getFichaVehiculos() {
		return this.fichaVehiculos;
	}

	public void setFichaVehiculos(Set<FichaVehiculo> fichaVehiculos) {
		this.fichaVehiculos = fichaVehiculos;
	}

}